Advertisement
nq1s788

22(хотя бы один из предыдущих процессов)

May 18th, 2024
588
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. data = open('22 (4).csv').readlines()[1:]
  2. n = len(data)
  3. ids = {}
  4. tt = [0] * n
  5. prev = [[] for i in range(n)]
  6. for i in range(n):
  7.     ind, t, *args = data[i].split(';')[:-2]
  8.     ind = int(ind)
  9.     ids[ind] = i
  10.     t = int(t)
  11.     tt[i] = t
  12.     for e in args:
  13.         if e != '':
  14.             x = ids[int(e.replace('"', ''))]
  15.             prev[i].append(x)
  16. answ = [0] * n
  17. for i in range(n):
  18.     if len(prev[i]) != 0:
  19.         answ[i] = 1000000000000
  20.         for lst in prev[i]:
  21.             answ[i] = min(answ[i], answ[lst] + 3 + tt[i])
  22.     else:
  23.         answ[i] = tt[i]
  24. print(max(answ))
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement